#include<iostream>
#include<algorithm>
using namespace std;
typedef struct {
	int w;
	int high;
}data;

bool cmp(data a,data b){
	if(a.w<b.w)
		return true;
	return false;
}
int main(){
	int s,n;
	data apps[5001];
	int l1,l2;
	cin>>n>>s;
	cin>>l1>>l2;
	int a,b;
	for(int i=0;i<n;i++){
		cin>>apps[i].high>>apps[i].w;
	}
	sort(apps,apps+n,cmp);
	int ans=0;
	for(int i=0;i<n;i++){ 
		if(apps[i].w<=s){
			if(apps[i].high<=l1+l2){
				ans++;
				s-=apps[i].w;
			}
		}
		else
			break;
	}
	cout<<ans;
}
